var gl_vue_vm_list_total_html = $('#vue_vm_list_total').html();
var gl_vue_vm_list_detail_html = $('#vue_vm_list_detail').html();

$(function() {
	$('#vue_vm_list_total').hide();
	$('#vue_vm_list_detail').hide();
});

roomAssetDamaged_findAll();
roomAssetDamaged_findBuilding();


function getTotal(todos) {
	var totalMoney = 0;
	for(var i=0; i<todos.length; i++) {
		var price = todos[i].price;
		var damagedQuantity = todos[i].damagedQuantity;
		totalMoney += parseFloat((price*damagedQuantity).toFixed(2));
	}
	
	return totalMoney;
}

function roomAssetDamaged_findAll() {
	if($('#vue_vm_list_total').length==0) {return;}
	$('#vue_vm_list_total').hide();

	findAll_basic(path+'/roomAssetDamaged/findAll', function(response) {
		$('#vue_vm_list_total').html(gl_vue_vm_list_total_html);
		
		new Vue({
			el: '#vue_vm_list_total',
			data: {
				todos: response.data
			},
			methods: {
				getAllTotal:function(todos) {
					return getTotal(todos);
				}
			}
		});
		
		$('#vue_vm_list_total').show();
	});
}

function roomAssetDamaged_findBuilding() {
	if($('#vue_vm_list_detail').length==0) {return;}
	$('#vue_vm_list_detail').hide();

	findAll_basic(path+'/roomAssetDamaged/findBuilding', function(response) {
		$('#vue_vm_list_detail').html(gl_vue_vm_list_detail_html);
		
		new Vue({
			el: '#vue_vm_list_detail',
			data: {
				todos: response.data
			},
			methods: {
				getBuildingTotal:function(baseAssetDamagedForms) {
					return getTotal(baseAssetDamagedForms);
				}
			}
		});
		
		$('#vue_vm_list_detail').show();
	});
}
